package com.richfit.barcodesystem_cczt.activitis.model.base;

import android.text.TextUtils;

public class Result<T> {
    public static String succ = "ok";
    public static String err = "error";
//    {
//        "status": "ok",
//            "info": "操作成功",
//            "data": [
//        {
//            "name": "JSESSIONID",
//                "value": "D8A3070E339E57AC4D574AB75B4AE1D2",
//                "version": 0,
//                "comment": "",
//                "domain": "",
//                "maxAge": -1,
//                "path": "",
//                "secure": false,
//                "httpOnly": false
//        }
//  ]
//    }
    /**
     * ok：成功；error：失败
     */
    private String status;
    private String info;
    private T data;
    private String token;
    private String cookie;

    public Result success(String message, T data, String token) {
        Result result = new Result();
        result.setStatus("ok");
        result.setInfo(message);
        result.setToken(token);
        return result;
    }

    public Result fail(String message) {
        Result result = new Result();
        result.setStatus("error");
        result.setInfo(message);
        return result;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getInfo() {
        return TextUtils.isEmpty(info) ? "错误" : info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public T getData() {
        return data;
    }


    public void setData(T data) {
        this.data = data;
    }

    public String getCookie() {
        return cookie;
    }

    public void setCookie(String cookie) {
        this.cookie = cookie;
    }
}
